package cn.edu.zafu.bigdata.lb;

import java.util.HashMap;
import java.util.Map;

public class StudentGradeManager {

    private Map<String, Integer> studentGrades;

    public StudentGradeManager() {
        studentGrades = new HashMap<>();
    }

    // 添加学生成绩
    public void addStudent(String name, int grade) {
        studentGrades.put(name, grade);
    }

    // 根据学生姓名获取成绩
    public int getGrade(String name) {
        return studentGrades.getOrDefault(name, -1);
    }

    // 删除学生成绩
    public void removeStudent(String name) {
        studentGrades.remove(name);
    }

    // 测试类
    public static void main(String[] args) {
        StudentGradeManager manager = new StudentGradeManager();

        // 添加学生成绩
        manager.addStudent("MaXiangDong", 93);
        manager.addStudent("WangChen", 87);
        manager.addStudent("LiuBo", 83);

        // 查询学生成绩
        System.out.println("MaXiangDong's grade: " + manager.getGrade("MaXiangDong"));
        System.out.println("WangChen's grade: " + manager.getGrade("WangChen"));
        System.out.println("LiuBo's grade: " + manager.getGrade("LiuBo"));
        System.out.println("ZhaoQiTao's grade: " + manager.getGrade("ZhaoQiTao"));

        // 删除学生成绩
        manager.removeStudent("WangChen");
        System.out.println("WangChen's grade after removal: " + manager.getGrade("WangChen"));
    }
}